package com.fintech.modules.demo;

import java.io.File;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fintech.modules.opensearch.SearchBiz;

public class Demo {
	private static Logger logger = LoggerFactory.getLogger(SearchBiz.class);
	
	public static void main(String[] args) {
		String path = "E:\\web\\data\\";
		
		checkExcel(path);
	}
	
	public static void checkExcel(String path){
		
        if(StringUtils.isEmpty(path)){
            path = "F:\\验证类项目\\tmpExcel解析导入openSearch\\2\\";
        }
        File directory = new File(path);
        File[] files = directory.listFiles();
        
        for(int i = 0;i < files.length;i ++){
        	File tmp = files[i];
        	//logger.info("file===="+tmp.getAbsolutePath());
            if(tmp.isDirectory()){
            	checkExcel(tmp.getAbsolutePath());
            }
            
            if(tmp.getName().endsWith("xls") || tmp.getName().endsWith(".xlsx")){
                try {
                	logger.info("====CG=读取Excel至String数组："+tmp.getAbsolutePath());
                	//move excel
                	String name = tmp.getName();
                	tmp.renameTo(new File("F:\\dataexcel\\"+name));
                }catch(IllegalArgumentException e1){
                    logger.error("==tmp.getAbsolutePath():"+tmp.getAbsolutePath(),e1.getMessage());
                }catch (Exception e) {
                	System.out.println("==Exception ==tmp.getAbsolutePath():"+tmp.getAbsolutePath());
                	e.printStackTrace();
                }
            }
            
        }
        
        
		        
	}

}
